import mysql.connector
import pandas as pd
from sqlalchemy import create_engine


# way 1
conn = mysql.connector.connect(
            host="localhost",
            user="ly",
            password="123456",
            database='test'
        )

df = pd.read_sql('SELECT * from person', conn)
print(df)

# way 2 recommended
url = 'mysql+mysqlconnector://ly:123456@localhost/test?charset=utf8'
engine = create_engine(url)
df = pd.read_sql('SELECT * from person', engine)
print(df)
